package com.mz.ozy.mvp.model;

import android.content.Context;
import android.text.TextUtils;

import com.mz.ozy.constants.Constants;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class ArticleModel {

    public Observable<ResponseBody> queryArticleType(Context context) {
        Map<String, String> jsonObject = new HashMap<>();
        jsonObject.put("pageNo", "0");
        jsonObject.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10160, JsonUtils.requestJsonDate(jsonObject), Constants.tokenId);
    }

    public Observable<ResponseBody> queryArticleListByType(Context context, String typename, String content, int pageNo) {
        Map<String, String> jsonObject = new HashMap<>();
        jsonObject.put("did", typename);
        if (!TextUtils.isEmpty(content)) {
            jsonObject.put("content", content);
        }
        jsonObject.put("pageNo", pageNo + "");
        jsonObject.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10160, JsonUtils.requestJsonDate(jsonObject), Constants.tokenId);
    }

    public Observable<ResponseBody> queryArticleDetail(Context context, int wid) {
        Map<String, String> jsonObject = new HashMap<>();
        jsonObject.put("tid", wid + "");
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10161, JsonUtils.requestJsonDate(jsonObject), Constants.tokenId);
    }

    public Observable<ResponseBody> followTheObject(Context context, int oid, int sType) {
        Map<String, String> maps = new HashMap<>();
        maps.put("cid", oid + "");
        maps.put("type", sType + "");
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10162, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }
}


